<?php

#error_reporting(E_ALL);
/***
	Class		adminfunctions
	Version		1.0
	Requires	nothing (_mysql.inc for constructor)
	Purpose		Creates a datingfunctions interface between website and database and handles flow of information between products, reviews, awards, configurations, options, types and navigation.
***/




class adminfunctions
{
	// Simply stores a reference to the database handler being used by the script in general
	var $dbh = null;
	var $general = null;
	
	function adminfunctions($dbh='')
	{
		$this->dbh = $dbh;
	}
	//******End of constructor of the class****

//========================Function to update the htaccess file ===============

function checkfiletype($filename){
	$ekstensi=substr(strrchr($filename, "."), 1);
	if ($ekstensi=='JPG' || $ekstensi=='jpg' || $ekstensi=='jpeg' || $ekstensi=='JPEG' || $ekstensi=='gif' || $ekstensi=='GIF' || $ekstensi=='bmp' || $ekstensi=='BMP' || $ekstensi=='png' || $ekstensi=='PNG') 
		return 1;
	else
		echo '<script>alert("File Type not allowed");</script>';
}
function update_htaccess(){

//htaccess header
$htacc = "Options +FollowSymLinks\nRewriteEngine on";


//update main menu

$qry="select name,id,parent_id,do_edit,url_page from menu where deleted='N' and status='Y' and name!='' order by name";	
	$res=mysql_query($qry);
	while($row=mysql_fetch_object($res)){
	$row->name = str_replace(" ","",$row->name);
	
	if($row->do_edit=="Y" && (strtolower($row->name)!='logout') && ($row->url_page!="login.php?logout=1")){
		$htacc.="\nRewriteRule $row->name/$ index.php?show=common_page&id=$row->id";
		$htacc.="\nRewriteRule $row->name/(.*)/(.*)/$ index.php?show=common_page&id=$1&pid=$2";
		$htacc.="\nRewriteRule $row->name/(.*)/$ index.php?show=common_page&id=$1";
	}	
	 if(($row->url_page=="login.php?logout=1")||(strtolower($row->name)=='logout')){
	if($row->url_page=="")
			$row->url_page="common_page";
	
		$htacc.="\nRewriteRule $row->name/$ login.php?show=$row->url_page&id=$row->id&logout=1";
		
	}	
	else if($row->do_edit=="N"){
		if($row->url_page=="search_result")
			{
			$htacc.="\nRewriteRule Search/exl/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/$ index.php?show=search_result&keyword=$1&search_type=$2&menu_id1=$3&faq_search=$4&page_no=$6&next_page=$7";

			$htacc.="\nRewriteRule Search/exl/(.*)/(.*)/(.*)/(.*)/prev/(.*)/$ index.php?show=search_result&keyword=$1&search_type=$2&menu_id1=$3&faq_search=$4&page_no=$5";
			
			$htacc.="\nRewriteRule Search/Keyword/(.*)/(.*)/(.*)/(.*)/nxt/(.*)/(.*)/$ index.php?show=search_result&keyword=$1&search_type=$2&any_word=$3&ordering=$4&page_no=$5&next_page=$6";
			
			$htacc.="\nRewriteRule Search/Keyword/(.*)/(.*)/(.*)/(.*)/prev/(.*)/$ index.php?show=search_result&keyword=$1&search_type=$2&any_word=$3&ordering=$4&page_no=$5&next_page=$6";
			
			$htacc.="\nRewriteRule Search/Keyword/(.*)/(.*)/prev/(.*)/$ index.php?show=search_result&keyword=$1&search_type=$2&page_no=$3";
			
			$htacc.="\nRewriteRule Search/Keyword/(.*)/(.*)/nxt/(.*)/(.*)/$ index.php?show=search_result&keyword=$1&search_type=$2&page_no=$3&next_page=$4";
			
			$htacc.="\nRewriteRule Search/Keyword/(.*)/(.*)/end/(.*)/(.*)/$ index.php?show=search_result&keyword=$1&search_type=$2&page_no=$3&next_page=$4";
			
			$htacc.="\nRewriteRule Search/exl/(.*)/(.*)/(.*)/(.*)/$ index.php?show=search_result&keyword=$1&search_type=$2&menu_id1=$3&faq_search=$4";
			$htacc.="\nRewriteRule Search/Keyword/(.*)/(.*)/(.*)/(.*)/(.*)/$ index.php?show=search_result&keyword=$1&search_type=$2&page_no=$4&next_page=$5";
			$htacc.="\nRewriteRule Search/Keyword/(.*)/(.*)/prev/(.*)/$ index.php?show=search_result&keyword=$1&search_type=$2&page_no=$3";
			$htacc.="\nRewriteRule $row->name/$ index.php?show=$row->url_page&id=$row->id";
			$htacc.="\nRewriteRule $row->name/(.*)/(.*)/$ index.php?show=$row->url_page&id=$1&pid=$2";
			$htacc.="\nRewriteRule $row->name/(.*)/$ index.php?show=$row->url_page&id=$1";
			}
		else{
		
		if($row->url_page=="")
			$row->url_page="common_page";
			$htacc.="\nRewriteRule $row->name/$ index.php?show=$row->url_page&id=$row->id";
			$htacc.="\nRewriteRule $row->name/(.*)/(.*)/$ index.php?show=$row->url_page&id=$1&pid=$2";
			$htacc.="\nRewriteRule $row->name/(.*)/$ index.php?show=$row->url_page&id=$1";
			}
		}
	$htacc.="\nRewriteRule ForgotPassword/$ index.php?show=forgot_password";
	$htacc.="\nRewriteRule Registeration/$ index.php?show=registration";
	
	}
	
	//echo $htacc;exit;
	 echo "<b>Updating htaccess.....</b>";
	 $filename = ".htaccess";
	 $handle = fopen($filename, 'w');
	 fwrite($handle, $htacc);
	fclose($handle);
	
return 1;
}//end of function





//############### START  admin_header function ################
function adm_header()
{
	//
	//function to fetch the flags of the country
	//
	
	$adm_header='
	<?xml version="1.0" encoding="iso-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>KINI Indonesia - Administration Panel</title>
<link rel="stylesheet" href="show_files/template.css" type="text/css" />
<link rel="stylesheet" href="show_files/theme000.css" type="text/css" />
<script language="JavaScript" src="show_files/JSCookMe.js" type="text/javascript"></script>
<script language="JavaScript" src="show_files/theme000.js" type="text/javascript"></script>
<script language="JavaScript" src="show_files/joomla00.js" type="text/javascript"></script>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1;charset=windows-1252" />
<meta name="Generator" content="Joomla! Content Management System" />
<link rel="shortcut icon" href="show_files/favicon0.ico" />
</head>
<body>

<div id="wrapper">
	<div id="header">
			<div id="joomla"><img src="show_files/header_t.png" alt="KINI Logo" /></div>
	</div>
</div>
<table width="100%" class="menubar" cellpadding="0" cellspacing="0" border="0">
<tr>
	<td class="menubackgr" style="padding-left:5px;">
					<div id="myMenuID"></div>
			<script language="JavaScript" type="text/javascript">
			var myMenu =
			[
						[null,\'Home\',\'admin.php\',null,\'Control Panel\'],
				_cmSplit,
				[null,\'Catalog\',null,null,\'Product Management\',
					[\'<img src="assets/ThemeOffice/catalog.png" />\',\'Collection Manager\',\'admin.php?show=collection_manager\',\'\',\'Collection Manager\'],
					[\'<img src="assets/ThemeOffice/catalog.png" />\',\'Product Manager\',\'admin.php?show=product_manager\',\'\',\'Product Manager\'],
					_cmSplit,
					[\'<img src="assets/ThemeOffice/catalog.png" />\',\'Add New\',\'admin.php?show=add_product\',null,\'Add New Product\'],
				],
				_cmSplit,
				[null,\'User\',null,null,\'User Management\',
					[\'<img src="assets/ThemeOffice/users.png" />\',\'User Manager\',\'admin.php?show=user_manager\',null,\'User Manager\'],
					_cmSplit,
					[\'<img src="assets/ThemeOffice/user.png" />\',\'Show Inactive\',\'admin.php?show=user_manager&sort=inactive\',null,\'Show Inactive User\'],
					[\'<img src="assets/ThemeOffice/user.png" />\',\'Show Suspended\',\'admin.php?show=user_manager&sort=suspended\',null,\'Show Suspended User\'],
				],
				_cmSplit,
				[null,\'Content\',null,null,\'Content Management\',
					[\'<img src="assets/ThemeOffice/news.png" />\',\'News Manager\',\'admin.php?show=news_manager\',null,\'News Manager\'],
					[\'<img src="assets/ThemeOffice/agenda.png" />\',\'Agenda Manager\',\'admin.php?show=agenda_manager\',null,\'Agenda Manager\'],
				],
				_cmSplit,
				[null,\'Gallery\',null,null,\'Album Gallery\',
					[\'<img src="assets/ThemeOffice/albums.png" />\', \'Album Manager\', "admin.php?show=album_manager", null, \'Album Manager\'],
					[\'<img src="assets/ThemeOffice/add_album.png" />\', \'Add New Album\', "admin.php?show=add_album", null, \'Add New Album\'],
				_cmSplit,
					[\'<img src="assets/ThemeOffice/pictures.png" />\', \'Picture Manager\', "admin.php?show=gallery_manager", null, \'Gallery Manager\'],
					[\'<img src="assets/ThemeOffice/add_picture.png" />\', \'Add New Picture\', "admin.php?show=add_gallery", null, \'Add New Picture\'],
				],
				_cmSplit,
				[null,\'Configuration\',null,null,\'Site Configuration\',
					[\'<img src="assets/ThemeOffice/module.png" />\', \'Site Configuration\', "admin.php?show=configuration", null, \'Site Configuration\',null],
				],
			];
			cmDraw (\'myMenuID\', myMenu, \'hbr\', cmThemeOffice, \'ThemeOffice\');
			</script>
		</td>
	<td class="menubackgr" align="right">
		<a href="http://www.kinifurniture.com/" target="_blank">
			Preview</a>
	</td>
	<td class="menubackgr" align="right" style="padding-right:5px;">
		<a href="admin.php?show=login&logout=1" style="color: #333333; font-weight: bold">
			Logout</a>
		<strong>admin</strong>
	</td>
</tr>
</table>
';

	return $adm_header;

}//********** END  left_menu function *********

//############### START  admin_header function ################
function admin_header()
{
   global $SITE_TITLE, $SITE_EMAIL;
	//
	//function to fetch the flags of the country
	//
	// $Flags=$this->Get_flag();

$admin_header='<tr>
				<td align="left" valign="top" style="background:url(images/top_header.jpg) repeat-x">
					<table width="100%" border="0" cellspacing="0" cellpadding="4" height="64" style="background: url(images/admin_interface.jpg) no-repeat; background-position:top left;">
						<tr><td class="logo1" valign="top">'.$SITE_TITLE.'</td>
                        <td valign="top" align="right">
	 <table width="95%" border="0" cellspacing="0" cellpadding="0">
	<tr><td height="5"></td></tr>
  <tr>
  	<td class="top_menu">Logged in : '.$_SESSION['admin_email'].'</td>
	<td class="top_menu" align="center">||</td>
	<td class="top_menu">IP : '.$_SERVER[REMOTE_ADDR].'</td>
	<td class="top_menu" align="center">||</td>
    <td class="top_menu">Welcome '.ucfirst($_SESSION['admin_name']).'</td>
    <td class="top_menu" align="center">||</td>
    <td class="top_menu"><a href="admin.php?show=login&logout=1" target="_parent"><b>Logout</b></a></td>
  </tr>
	<tr><td height="5"></td></tr>
									<tr>
									<td align="right" colspan="9">
														<p class="sys_time"><iframe frameborder="0" marginheight="0" scrolling="no" marginwidth="0" width="410" height="18" src="./clock.php"></iframe>
										
														</p>
													</td>
									</tr>
</table>
</td>
                        </tr>
    
					</table></td></tr>';

	return $admin_header;

}//********** END  left_menu function *********

//############### START  is_login function ################
	
function is_admin_login()
{		
	if(!$_SESSION['admin_id'])	
			echo'<script>window.open("admin.php?show=login", "_parent");</script>';
			
	
}

//********** END  is_login function *********


//*********************************
// 	 FUNCTION FOR REVERSE DATE    *
//								  *
//*********************************
	
function revdate1($date)
{
	 $date1=explode("-",$date);	
	 $currdate=$date1[2].'-'.$date1[1].'-'.$date1[0];
	 return $currdate;
}

				

//=============Get Parent Name=====================

function parent_name($pid)
{
	$sql="select name from menu where parent_id='0' and id='$pid'";
	$sqlResult=$this->dbh->query($sql);
	$sqlRow=mysql_fetch_object($sqlResult);
	return $sqlRow->name;
}
//End of function parent_name()


//=============Get Auction Code=====================

function Get_auction($item_id)
{
	$sql="select auction_code from bid where id='$item_id'";
	$sqlResult=$this->dbh->query($sql);
	$sqlRow=mysql_fetch_object($sqlResult);
	return $sqlRow->auction_code;
}
//End of function Get_auction()

//=============Get Auction Name=====================

function Get_auction_name($item_id)
{
	$sql="select title from bid where id='$item_id'";
	$sqlResult=$this->dbh->query($sql);
	$sqlRow=mysql_fetch_object($sqlResult);
	return $sqlRow->title;
}
//End of function Get_auction_name()

//=============Get Auction Status====================

function Get_auction_status($item_id)
{
	$sql="select running,end_bid from bid where id='$item_id'";
	$sqlResult=$this->dbh->query($sql);
	$sqlRow=mysql_fetch_object($sqlResult);
	
	if($sqlRow->end_bid!='Y')
	{
		if($sqlRow->running=='Y')
			$status='Running';
		else if($sqlRow->running=='N')
			$status='Paused';
	}
	else
		$status='Expired';
		
	return $status;
}
//End of function Get_auction_status()


//############### START  pop_up_header function ################
function pop_up_header()
{
	//
	//function to fetch the flags of the country
	//
	 //$Flags=$this->Get_flag();

	$pop_up_header='<table cellpadding="0" cellspacing="0" border="0" bgcolor="#1A2155">					
							<tr>
								<td valign="top" width="25%" align="center" bgcolor="#1A2155">
								  <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="204" height="124">
                                      <param name="movie" value="flash/logo_animation.swf">
                                      <param name="quality" value="high">
                                      <embed src="flash/logo_animation.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="204" height="124"></embed>
								  </object>								</td>
								<td align="center" valign="middle">
									<h3><font color="#FFFFFF"> Administrator Interface</font></h3></td></tr></table>';						

	return $pop_up_header;

}//********** END  pop_up_header function *********


//================ FETCH MENU NAME FOR TESTIMONIAL=============
function fetch_menu_name($menu_id)
	{
		$sql="select * from menu where id in('$menu_id')";
		$res=$this->dbh->query($sql);
		while($row=@mysql_fetch_object($res))
			$m_name.=$row->name.', ';
			
		$m_name=substr($m_name,0,strlen($m_name)-2);
		return $m_name;
	}		
	
//===========================================================

function makePics($imgFullPath,$identify)
{ 
	$myPath=explode("/",$imgFullPath);
	list($width, $height, $type, $attr) = getimagesize($imgFullPath);
	
	$thumb=new thumbnail($imgFullPath);
	$NOimages=3;
$i=1;


while( $i <= $NOimages)
	{
	if($i==1)
		{
		$doResize=0;
			if($width>120 && $height>110 )
				{
					$thumb->size_width(120);                // set width for thumbnail, or 
					$thumb->size_height(110);               // set height for thumbnail, or 
					$thumb->size_auto(120);                 // set the biggest width or height for thumbnail 
					                
					$doResize=1; 
				}
		$filenamary = explode("/",$url_cont);
		$count = count($filenamary);
		$filename = $filenamary[$count-1];
		
 		if($doResize){	
			$Preview_path=$myPath[0]."/".$myPath[1]."/".$myPath[2];
				$Pre_path=$this->getPath($Preview_path,"Thumb");
				$thumb->save("$Pre_path"); 	
		}
		else
		{ 
		   	$Preview_path=$myPath[0]."/".$myPath[1]."/".$myPath[2];
			$Pre_path=$this->getPath($Preview_path,"Thumb");
			copy("$imgFullPath",$Pre_path);
		}
		$i++;
	}	
		
	if($i==2)
		{
			$doResize=0;
			if($width>131 && $height>178 )
				{
					$thumb->size_width(131);                // set width for thumbnail, or 
					$thumb->size_height(178);               // set height for thumbnail, or 
					$thumb->size_auto(178);                 // set the biggest width or height for thumbnail 
					                
					$doResize=1; 
				}
		$filenamary = explode("/",$url_cont);
		$count = count($filenamary);
		$filename = $filenamary[$count-1];
		
 		if($doResize){	
				$Preview_path=$myPath[0]."/".$myPath[1]."/".$myPath[2];
				$Pre_path=$this->getPath($Preview_path,"Main");
				$thumb->save("$Pre_path"); 	
		}	
		else
		{ 
		   $Preview_path=$myPath[0]."/".$myPath[1]."/".$myPath[2];
			$Pre_path=$this->getPath($Preview_path,"Main");
			copy("$imgFullPath",$Pre_path); 
		}
		$i++;
	}
	
	if($i==3)
		{
		$doResize=0;
			if($width>400 && $height>500 )
				{
				
					$thumb->size_width(400);                // set width for thumbnail, or 
					$thumb->size_height(500);               // set height for thumbnail, or 
					$thumb->size_auto(500);                 // set the biggest width or height for thumbnail 
					                
					$doResize=1; 
				}
		$filenamary = explode("/",$url_cont);
		$count = count($filenamary);
		$filename = $filenamary[$count-1];
	
 		if($doResize){
				$Preview_path=$myPath[0]."/".$myPath[1]."/".$myPath[2];
				$Pre_path=$this->getPath($Preview_path,"Zoom");
				$thumb->save("$Pre_path"); 	
		}	
		else
		{ 
		   $Preview_path=$myPath[0]."/".$myPath[1]."/".$myPath[2];
			$Pre_path=$this->getPath($Preview_path,"Zoom");
			copy("$imgFullPath",$Pre_path); 
		}
		$i++;
	}
	
		
	}	
}//end of function


//
//==========get path====
//
function getPath($path, $prefix)
{
	 //find directory name
	$dir_name= dirname($path);
	 //create thumbnail path	
	$pic_path="/".$prefix."_".basename($path);
	 //new path	
	$new_path=$dir_name.$pic_path;
	return $new_path;			
}//end of function
//
//===========================================================

//==================================== GET HOUR========================================

function Get_hour($name,$hour)
	{
	$Hours = array(0=>'01' ,1=>'02', 2=>'03',3=> '04', 4=> '05', 5=>'06',6=> '07',7=> '08',8=>'09',9=>10, 10=>11,11=> 12);
	$i=0;
	
	$Hour='<select name="'.$name.'" >
			<option value="" selected>--</option>';
	
	while($i<count($Hours))
		{
		if($hour==$Hours[$i])
			$Hour.='<option value="'.$Hours[$i].'" selected>'.$Hours[$i].'</option>';
		else
			$Hour.='<option value="'.$Hours[$i].'" >'.$Hours[$i].'</option>';
		$i++;
		}
		
		$Hour.='</select>';
	return $Hour;	
	}

//==================================== GET MIN========================================

function Get_min($name,$min)
	{
	$Hours = array(0=>'00' ,1=>'05', 2=>'10',3=> '15', 4=> '20', 5=>'25',6=> '30',7=> '35',8=>'40',9=>45, 10=>50,11=> 55);
	$i=0;
	
	$Hour='<select name="'.$name.'" >
			<option value="" selected>--</option>';
	
	while($i<count($Hours))
		{
		if($min==$Hours[$i])
			$Hour.='<option value="'.$Hours[$i].'" selected>'.$Hours[$i].'</option>';
		else	
			$Hour.='<option value="'.$Hours[$i].'" >'.$Hours[$i].'</option>';
		$i++;
		}
		
		$Hour.='</select>';
	return $Hour;	
	}
	
function Get_Bus_Type($b_type,$name)
	{
	if($b_type=='')
	$Firstoption='<option value="">Please Select</option>';
else
	$Firstoption='<option value="'.$b_type.'">'.$b_type.'</option>';	

$Bus_Type='<select name="'.$name.'">
											'.$Firstoption.'	
												<option value="Private">Private</option>
											<option value="Personal">Personal</option>
										</select>';
									 
	return $Bus_Type;
	}
	
	function Get_passengers($passengers,$name)
	{
	if($passengers=='')
	$Firstoption='<option value="">Please Select</option>';
else
	$Firstoption='<option value="'.$passengers.'">'.$passengers.'</option>';	

$Passengers='<select class="txt10px" name="'.$name.'">
											'.$Firstoption.'	
												<option value="5-10">5-10</option>
											<option value="10-15">10-15</option>
											<option value="15-20">15-20</option>
											<option value="20-25">20-25</option>
											<option value="25-30">25-30</option>
											<option value="30-35">30-35</option>
											<option value="35-40">35-40</option>
											<option value="40-45">40-45</option>
											<option value="45-50">45-50</option>
											</select>';
									 
	return $Passengers;
	}
	
	
function Get_Country($country)
 	{
	$qry1="SELECT * FROM country order by id";
	$Res=$this->dbh->query($qry1);
			
	$Country_dropdown='<select name="id_country" class="select_drop" style="width:135px;">';
	while($row=mysql_fetch_object($Res))
		{
		 if($country==$row->id)
			$Country_dropdown.='<option value='.$row->id.' selected>'.$row->name.'</option>';
		 else
			$Country_dropdown.='<option value='.$row->id.'>'.$row->name.'</option>';	
		}						
							
		    $Country_dropdown.='</select>';
	
	
		return $Country_dropdown;	

	}	
//END OF FUNCTION	
//======================================= GET STATE ===========================

function Get_state($statename)
	{
	
	$Stata_list = array('New South Wales', 'Australian Capital Territory', 'Northern Territory','Queensland','South Australia','Tasmania'
	,'Victoria','Western Australia','Ashmore and Cartier Islands','Coral Sea Islands Territory');
	
	$State_Dropdown='<select class="selectbox_90" name="state" onchange="SelectCity(this.value,city_div);">';
	while (list($key, $value) = each($Stata_list)) 
		{
		if($statename==strtolower($value))
			$State_Dropdown.='<option value="'.$value.'" selected>'.$value.'</option>';
		else
			$State_Dropdown.='<option value="'.$value.'">'.$value.'</option>';
		}
	$State_Dropdown.='</select>';
	
	return $State_Dropdown;
	}

	function getActiondesc1($type)	
	{
					
					
					if($type=='faq' || $type=='user' || $type=='logo' || $type=='flags')
					{		
					
					$image.="<td align=right valign='top'><img src='images/admin/active.gif ' border=0></td><td valign='top'   class='admin_text'> Active</td>
							<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>";
					$image.="<td align=right valign='top'><img src='images/admin/inactive.gif ' border=0 ></td><td valign='top'  class='admin_text'>Inactive</td>
							<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>";
					$image.="<td align=right valign='top'><img src='images/admin/view.gif ' border=0></td><td valign='top'  class='admin_text'>View </td>
							<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>";			
					}
					
					if($type=='static' || $type=='advert' || $type=='news')
					{		
					
					$image.="<td align=right valign='top'><img src='images/admin/active.gif ' border=0></td><td valign='top'   class='admin_text'> Active</td>
							<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>";
					$image.="<td align=right valign='top'><img src='images/admin/inactive.gif ' border=0 ></td><td valign='top'  class='admin_text'>Inactive</td>
							<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>";
	
					}
						
					
					if( $type=='press' || $type=='features' || $type=='tour' || $type=='product'  || $type=='vehicle' )
					{
					$image.="<td align=right valign='top'><img src='images/admin/active.gif ' border=0></td><td valign='top'  class='admin_text'> Active</td> 
							<td>&nbsp;&nbsp;&nbsp;&nbsp;</td> ";
					$image.="<td align=right valign='top'><img src='images/admin/inactive.gif ' border=0></td><td valign='top'  class='admin_text'>Inactive</td>
							<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>";									
					$image.="<td align=right valign='top'><img src='images/admin/up.gif ' border=0></td><td valign='top'  class='admin_text'>Up</td>
							<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>";			
					$image.="<td align=right valign='top'><img src='images/admin/view.gif ' border=0></td><td valign='top'  class='admin_text'>View </td>
							<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>";	
					}
					
					if($type=='menu')
					{
					$image.="<td align=right valign='top'><img src='images/admin/doNOTdelete.gif ' border=0></td><td valign='top'  class='admin_text'>Do Not Delete </td>
							<td>&nbsp;&nbsp;</td>";	
					$image.="<td align=right valign='top'><img src='images/admin/doNOTedit.gif ' border=0></td><td valign='top'  class='admin_text'>Do Not Edit </td>
							<td>&nbsp;&nbsp;</td>";	
					$image.="<td align=right valign='top'><img src='images/admin/active.gif ' border=0></td><td valign='top'  class='admin_text'> Active</td> 
							<td>&nbsp;&nbsp;</td> ";
					$image.="<td align=right valign='top'><img src='images/admin/inactive.gif ' border=0></td><td valign='top'  class='admin_text'>Inactive</td>
							<td>&nbsp;&nbsp;</td>";									
					$image.="<td align=right valign='top'><img src='images/admin/up.gif ' border=0></td><td valign='top'  class='admin_text'> Up</td>
							<td>&nbsp;&nbsp;</td>";			
					$image.="<td align=right valign='top'><img src='images/admin/view.gif ' border=0></td><td valign='top'  class='admin_text'>View </td>
							<td>&nbsp;&nbsp;</td>";	
					}
					if ($type=='pro_booking' || $type=='category' || $type=='destination')
					{
					$image.="<td align=right valign='top'><img src='images/admin/view.gif ' border=0></td><td valign='top'  class='admin_text'>View </td>
							<td>&nbsp;&nbsp;</td>";
					$image.="<td align=right valign='top'><img src='images/admin/active.gif ' border=0></td><td valign='top'  class='admin_text'> Active</td> 
							<td>&nbsp;&nbsp;</td> ";
					$image.="<td align=right valign='top'><img src='images/admin/inactive.gif ' border=0></td><td valign='top'  class='admin_text'>Inactive</td>
							<td>&nbsp;&nbsp;</td>";									
						
					}
					
					
				
					
					if($type=='visitor' || $type=='transfer' || $type=='autobid')
					{
					$image="<td align=right valign='top'><img src='images/admin/delete.gif ' border=0 ></td>
							<td valign='top'  class='admin_text'> Delete</td><td>&nbsp;&nbsp;&nbsp;&nbsp;</td>";
		
					
					}
					
					if($type=='gallery'  || $type=='postcode')
					{
					$image="<td align=right valign='top'><img src='images/admin/edit.gif' border=0></td>
							<td valign='top' align=left  class='admin_text'>Edit</td><td>&nbsp;&nbsp;&nbsp;&nbsp;</td>" ;
					$image.="<td align=right valign='top'><img src='images/admin/delete.gif ' border=0 ></td>
							<td valign='top'  class='admin_text'> Delete</td><td>&nbsp;&nbsp;&nbsp;&nbsp;</td>";
		
					
					}
					if($type=='email')
					{
					$image="<td align=right valign='top'  class='admin_text'><img src='images/admin/edit.gif' border=0></td>
							<td valign='top' align=left>Edit</td><td>&nbsp;&nbsp;&nbsp;&nbsp;</td>" ;
					$image.="<td align=right valign='top'  class='admin_text'><img src='images/admin/view.gif ' border=0></td><td valign='top'>View </td>
							<td>&nbsp;&nbsp;&nbsp;&nbsp;</td> ";
					$image.="<td align=right valign='top'  class='admin_text'><img src='images/admin/active.gif ' border=0></td><td valign='top'> Active</td> 
							<td>&nbsp;&nbsp;&nbsp;&nbsp;</td> ";
					$image.="<td align=right valign='top'  class='admin_text'><img src='images/admin/inactive.gif ' border=0></td><td valign='top'>Inactive</td>
							<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>";									
					
					
					}
					
					if($type!='booking' && $type!='view_expire' && $type!='contact' && $type!='autobid')
					{				
					$image.="<td align=right valign='top'><img src='images/admin/edit.gif' border=0></td>
							<td valign='top' align=left  class='admin_text'>Edit</td><td>&nbsp;&nbsp;&nbsp;&nbsp;</td>" ;
					$image.="<td align=right valign='top'><img src='images/admin/delete.gif ' border=0 ></td>
							<td valign='top'  class='admin_text'> Delete</td><td>&nbsp;&nbsp;&nbsp;&nbsp;</td>";
					}
					if($type=='contact' || $type=='inquiry'|| $type=='booking' || $type=='view_expire')
					{
					$image.="<td align=right valign='top'><img src='images/admin/view.gif ' border=0></td><td valign='top'  class='admin_text'>View </td>
							<td>&nbsp;&nbsp;&nbsp;&nbsp;</td> ";
					$image.="<td align=right valign='top'><img src='images/admin/delete.gif ' border=0 ></td>
							<td valign='top'  class='admin_text'> Delete</td><td>&nbsp;&nbsp;&nbsp;&nbsp;</td>";
		
					
					}
					
					if($type=='credit')
					{
					$image="<td align=right valign='top'><img src='images/admin/active.gif ' border=0></td><td valign='top'  class='admin_text'> Active</td> 
							<td>&nbsp;&nbsp;</td> ";
					$image.="<td align=right valign='top'><img src='images/admin/inactive.gif ' border=0></td><td valign='top'  class='admin_text'>Inactive</td>
							<td>&nbsp;&nbsp;</td>";	
					$image.="<td align=right valign='top'><img src='images/admin/delete.gif ' border=0 ></td>
							<td valign='top'  class='admin_text'> Delete</td><td>&nbsp;&nbsp;&nbsp;&nbsp;</td>";
		
					
					}
					
					if($type=='emaillist')
					{
					$image="<td align=right valign='top'><img src='images/admin/edit.gif' border=0></td>
							<td valign='top' align=left  class='admin_text'>Edit</td><td>&nbsp;&nbsp;&nbsp;&nbsp;</td>" ;
				
					}
					
					
		$image="<br/><table border='0' cellspacing='0' cellpadding='2'><tr >$image</tr></table><br/>";
		return $image;

	}

//================== Function for particular Email ===========================================


function Email_info($id)
 	{
	$Res=$this->dbh->query("select subject,message from email where id='$id'");
	$Data=@mysql_fetch_array($Res);
	return $Data;
	}
	
function Get_Email($user_id)
 	{
	$Res=$this->dbh->query("select email from anggota where user_id='$user_id'");
	$Data=@mysql_fetch_object($Res);
	return $Data->email;
	}

//============================================
	//======== SEND A EMAIL =====================
	
	function Send_mail($to_email, $subject, $message, $from_name, $from_email)
	{
		
		$mail = new PHPMailer();
		$mail->FromName =$from_name;
		$mail->From     =$from_email;  
		$mail->AddAddress($to_email); 
		
		$mail->WordWrap = 50;                              // set word wrap
		$mail->IsHTML(true);                               // send as HTML
		$mail->Subject  =  $subject;
		$mail->Body     =  $message;

		$mail->Send();	 
		
	}//END OF Send_mail()		


//======================= GET DURATION ==================

function Get_Max_bid($auction_id)
	{
	$Res=$this->dbh->query("select max(bid_rate) as Maxbid from add_bids where item_id='$auction_id'");  
	$Data=@mysql_fetch_object($Res);
	if($Data->Maxbid)
		return $Data->Maxbid;
	else
		return 0;	
	}	

//========================= GET Max Min Bids ===================

function Get_Bid($item_id,$Bid_type)
	{
	
	if($Bid_type=='Max')
		$Qry="Select max(bid_rate) from add_bids where item_id='$item_id'"; 
	else if($Bid_type=='Min')
		$Qry="Select min(bid_rate) from add_bids where item_id='$item_id'"; 
	else if($Bid_type=='Total')
		 $Qry="Select count(*) from add_bids where item_id='$item_id'";	
		
	$Res=$this->dbh->query($Qry);
	$Data=@mysql_fetch_array($Res);
	
	if($Data[0])
		return $Data[0];
	else
		{
		if($Bid_type=='Total')
			return 0;
		else
			{
				$Res1=$this->dbh->query("Select bid_rate from bid where id='$item_id'");
				$Data1=@mysql_fetch_array($Res1);	
				return $Data1[0];
			}	
		}	
	}
		
function Get_Total_bid($auction_id)
	{
	$Res=$this->dbh->query("select * from add_bids where item_id='$auction_id'");  
	return @mysql_num_rows($Res);
	}

function Get_Total_Autobid($auction_id)
	{
	$Res=$this->dbh->query("select * from auto_bid where item_id='$auction_id' and status='Y'");  
	return @mysql_num_rows($Res);
	}	
	
function Get_winner($auction_id)
	{
	$Res=$this->dbh->query("select mobile_no,user_id from add_bids where bid_rate=(select max(bid_rate) from add_bids where item_id='$auction_id') and item_id='$auction_id'");  
	$Data=@mysql_fetch_object($Res);

	if($Data->user_id=='0')
		return $Data->mobile_no;
	else 
	{
		$user_name=$this->Get_username($Data->user_id);
		$user_type=$this->Get_user_field($Data->user_id,'user_type');
		
		return $user_name."<br>".$user_type;
	}

	}
	
function Get_user_field($user_id,$field_name)
{
	$Qry="select $field_name from anggota where user_id='$user_id'";
	$Res=$this->dbh->query($Qry);
	$Data=@mysql_fetch_object($Res);
	
	return $Data->$field_name;
}
	
function Get_Country_value($country)
 	{
	$qry1="SELECT * FROM country where id='$country'";
	$Res=$this->dbh->query($qry1);
	
	$row=mysql_fetch_object($Res);
	return $row->name;	

	}	
//END OF FUNCTION		

//============== GET VIRIFY CODE ==============

function Get_auction_code()
	{
	$string = 'dfsicjkxcvXSNxmaOZpqxnQDlaciwalaciAghakckUIy';
	$shuffle = str_shuffle($string);
	$random_chars = substr($shuffle, 0, 4);
	$random_chars2 = substr(str_shuffle('dfsicjkxcvXSNxmaOZpqxnQDlaciwalaciAghakckUIy'), 0, 4);
	return strtoupper($random_chars2);
	}


//===================== GET MONTH DROPDOWN===================

function Get_month($Month)
	{
$Month_array = array(1=>"January","February","March","April","May","June","July","August","September","October","November","December");

$Month_dropdown='<select name="Date_Month" id=Date_Month>';

while (list($key, $value) = each($Month_array))
	 {
	 	if($key==$Month)
			$Month_dropdown.='<option value="'.$key.'" selected>'.$value.'</option>';
		else
			$Month_dropdown.='<option value="'.$key.'">'.$value.'</option>';
			
	 }	
$Month_dropdown.='</select>';	

return  $Month_dropdown;
	} 
	
//===================== GET DAY DROPDOWN===================

function Get_day($day)
	{
	$Day_dropdown='<select name="Date_Day" id=Date_Day>';

	$i=1;
while ($i<=31)
	 {
	 	if($i==$day)
			$Day_dropdown.='<option value="'.$i.'" selected>'.$i.'</option>';
		else
			$Day_dropdown.='<option value="'.$i.'">'.$i.'</option>';
		$i++;	
	 }	
	$Day_dropdown.='</select>';	

	return  $Day_dropdown;
	} 	

//===================== GET DAY DROPDOWN===================

function Get_Year($year)
	{
	$Year_dropdown='<select name="Date_Year" id=Date_Year>';

	
	$Start_year=date("Y")-100;
	$End_year=date("Y")-18;
	
while ($End_year>=$Start_year)
	 {
	 	if($End_year==$year)
			$Year_dropdown.='<option value="'.$End_year.'" selected>'.$End_year.'</option>';
		else
			$Year_dropdown.='<option value="'.$End_year.'">'.$End_year.'</option>';
		$End_year--;	
	 }	
	$Year_dropdown.='</select>';	

	return  $Year_dropdown;
	} 
	
	//
	//Function for get user list
	//
	function getUserList()
	{
		$select=$this->dbh->query("select username,user_id from anggota where active='Y' and suspend='N' order by username");
		$user_dd="<option value=''>Please Select</option>";
		while($sqlRow=mysql_fetch_object($select))
			$user_dd.="<option value='$sqlRow->user_id'>".$sqlRow->username."</option>";
		return $user_dd;
	}

	function getPackageList()
	{
		$select=$this->dbh->query("select id,package,credit from credit_cost where status='Y' and deleted='N' order by id");
		$package_dd="<option value=''>Please Select</option>";
		while($sqlRow=mysql_fetch_object($select))
			$package_dd.="<option value='$sqlRow->id'>".$sqlRow->package."</option>";
		return $package_dd;
	}

function hhmmss($length) {
	$hrs = floor($length / 3600);
	$min = $length - $hrs * 3600;
	$min = floor($min / 60);
	$sec = $length - $hrs * 3600 - $min * 60;
	return	str_pad($hrs,2,'0',STR_PAD_LEFT) . ':' .
		str_pad($min,2,'0',STR_PAD_LEFT) . ':' .
		str_pad($sec,2,'0',STR_PAD_LEFT);
}
	
function check_auction_code($auction_code)
{
	$Res=$this->dbh->query("select * from bid where auction_code='$auction_code' and  deleted='N'");  
	return @mysql_num_rows($Res);
}
	
//============================ GET Timestamp=====================================
function get_com_timestamp($time, $date)
{
	$yy=substr($date, 0, 4);
	$mm=substr($date, 5, 2);
	$dd=substr($date, 8, 2);
	
	$hh=substr($time, 0, 2);
	$mm1=substr($time, 3, 2);
	$ss=substr($time, 6, 2);

	$timestamp=mktime($hh,$mm1,$ss,$mm,$dd,$yy);
	
	return $timestamp;
}	

function Get_username($user_id)
	{
	$Res=$this->dbh->query("select username from anggota where user_id='$user_id'");
	$Data=@mysql_fetch_object($Res);
	return $Data->username;

	}

function Time_Format12($t1)//23:20:00
{
	$ar1=explode(":", $t1);
	if($ar1[0]>=12)
	{
	 if($ar1[0]==12)
	{
	 $st1=12;
	 return $st1.':'.$ar1[1].':'.$ar1[2].' PM';
	 }
	 if($ar1[0]==23)
	{
	   $st1=11;
	  return $st1.':'.$ar1[1].':'.$ar1[2].' PM';
	 }
	 if($ar1[0]==22)
	{
	   $st1=10;
	  return $st1.':'.$ar1[1].':'.$ar1[2].' PM';
	 }
	if($ar1[0]>=9)
	{
		$st1=$ar1[0]-12;
		return '0'.$st1.':'.$ar1[1].':'.$ar1[2].' PM';
	}
	}
	else
	{
		return $t1.' AM';
	}	
}
function get_category($category)
{

$fieldname="cat_name".$_SESSION['LANG']; 

$Res=$this->dbh->query("select $fieldname from category where deleted='N' and id='$category'");
$Data=@mysql_fetch_array($Res);
return $Data[0];
}
function Time_Format24($t1)//12:20:00 PM
{
	$ar1=explode(":", $t1);	
	$ar2=explode(" ", $ar1[2]);
	if($ar2[1]==AM)
	{
		return $ar1[0].':'.$ar1[1].':'.$ar2[0];
	}
	else
	{
		if($ar1[0]==12)
			$st1=12;
		else
			$st1=$ar1[0]+12;
		return $st1.':'.$ar1[1].':'.$ar2[0];
	}
}	


function get_date_format($g_date)
{
	$check=explode(" ",$g_date);
	$date=$check[0]; 
	$time=$check[1];
    $right_date=$this->revdate1($date);

	$date_format=$time." ".$right_date;

	return $date_format;
}


function getCostCredit($bid_cost)
{
	$sqlResult=$this->dbh->query("select credit from credit_cost where id='$bid_cost'");
	$sqlRow=mysql_fetch_object($sqlResult);
	$bid_amt=$sqlRow->credit;
	
	return $bid_amt;
}

function revdate_new($date)
{
	 $param=explode(" ",$date);
	 $date1=$param[0];
	 $time=$param[1];
	 $param2=explode("-",$date1);	
	 $currdate=$time.' '.$param2[2].'-'.$param2[1].'-'.$param2[0];
	 return $currdate;
}	

function GetAutobidCount($userid)
{
      $count=0;
      $sql=$this->dbh->query("SELECT count(*) as reccount FROM auto_bid AS AB left join bid as B on AB.item_id=B.id WHERE AB.deleted='N' and AB.user_id='$userid' group by AB.user_id");
	  $sqlResult=mysql_fetch_object($sql);
	  if($this->dbh->num_rows()>0){
	       $count=$sqlResult->reccount;
	  }	   
	  return $count;
}

function GetFriendCount($userid)
{
      $count=0;
      $sql=$this->dbh->query("select count(*) as reccount from anggota where tell_friend='$userid' group by user_id ");
	  $sqlResult=mysql_fetch_object($sql);
	  if($this->dbh->num_rows()>0){
	       $count=$sqlResult->reccount;
	  }	   
	  return $count;
}

function GetWinHistoryCount($userid)
{
      $count=0;
      $sql=$this->dbh->query("select * from winners as w left join bid as a on w.bid_id=a.id where w.user_id='$userid' group by w.bid_id");
	  if($this->dbh->num_rows()>0)
	  {
		  while($sqlResult=mysql_fetch_object($sql))
			  {
					$count++;
			  }	
	  }   
	  return $count;
}

function GetPlaceBidCount($userid)
{
      $count=0;
      $sql=$this->dbh->query("select count(distinct item_id) as reccount from add_bids where user_id='$userid' ");
	  $sqlResult=mysql_fetch_object($sql);
	  if($this->dbh->num_rows()>0){
	       $count=$sqlResult->reccount;
	  }	   
	  return $count;
}

function GetDepositCount($userid)
{
      $count=0;
      $sql=$this->dbh->query("select count(*) as reccount from amount_transfer where user_id='$userid' group by user_id ");
	  $sqlResult=mysql_fetch_object($sql);
	  if($this->dbh->num_rows()>0){
	       $count=$sqlResult->reccount;
	  }	   
	  return $count;
}

function GetPaymentCount($userid)
{
      $count=0;
      $sql=$this->dbh->query("select count(*) as reccount from account where deleted='N' and user_id='$userid' group by user_id ");
	  $sqlResult=mysql_fetch_object($sql);
	  if($this->dbh->num_rows()>0){
	       $count=$sqlResult->reccount;
	  }	   
	  return $count;
}

function GetBiddingCount($userid)
{
      $count=0;
      $sql=$this->dbh->query("select count(*) as reccount from add_bids where user_id='$userid' group by user_id");
	  $sqlResult=mysql_fetch_object($sql);
	  if($this->dbh->num_rows()>0){
	       $count=$sqlResult->reccount;
	  }	   
	  return $count;
}

function GetWatchlistCount($userid)
{
      $count=0;
      $sql=$this->dbh->query("select count(*) as reccount from watchlist where user_id='$userid' group by user_id");
	  $sqlResult=mysql_fetch_object($sql);
	  if($this->dbh->num_rows()>0){
	       $count=$sqlResult->reccount;
	  }	   
	  return $count;
}

function get_total_contact()
{
	$sql4="select * from contact where checking='N' and deleted='N'";
	$sqlResult4=$this->dbh->query($sql4);
	return mysql_num_rows($sqlResult4);
}

function get_total_feedback()
{
	$sql4="select * from feedback where checking='N' and deleted='N'";
	$sqlResult4=$this->dbh->query($sql4);
	return mysql_num_rows($sqlResult4);
}

function get_total_payment_pending()
{
	$sql4="select * from account where deleted='N' and paystatus!='TRUE'";
	$sqlResult4=$this->dbh->query($sql4);
	return mysql_num_rows($sqlResult4);
}

function get_total_payment_success()
{
	$sql4="select * from account where deleted='N' and paystatus='TRUE'";
	$sqlResult4=$this->dbh->query($sql4);
	return mysql_num_rows($sqlResult4);
}

function get_total_auto_bid()
{
	$sql4="SELECT * FROM auto_bid AS AB LEFT JOIN users AS U ON AB.user_id = U.user_id left join bid as B on AB.item_id=B.id WHERE AB.deleted = 'N' AND AB.status = 'Y' and B.system_id='".$_SESSION['admin_id']."'";
	$sqlResult4=$this->dbh->query($sql4);
	return mysql_num_rows($sqlResult4);
}

function get_total_inactive_user()
{
	$sql4="select * from anggota where active='N'";
	$sqlResult4=$this->dbh->query($sql4);
	return mysql_num_rows($sqlResult4);
}

function get_total_online_user()
{
	$sql4="select * from anggota where online='Y'";
	$sqlResult4=$this->dbh->query($sql4);
	return mysql_num_rows($sqlResult4);
}

function get_total_active_user()
{
	$sql4="select * from anggota where active='Y'";
	$sqlResult4=$this->dbh->query($sql4);
	return mysql_num_rows($sqlResult4);
}

function get_total_offline_user()
{
	$sql4="select * from anggota where online='N'";
	$sqlResult4=$this->dbh->query($sql4);
	return mysql_num_rows($sqlResult4);
}

function get_total_unapprove_user()
{
	$sql4="select * from anggota where active='N'";
	$sqlResult4=$this->dbh->query($sql4);
	return mysql_num_rows($sqlResult4);
}

function get_total_approve_user()
{
	$sql4="select * from anggota where active='Y'";
	$sqlResult4=$this->dbh->query($sql4);
	return mysql_num_rows($sqlResult4);
}

function get_total_unsuspend_user()
{
	$sql4="select * from anggota where suspend='N'";
	$sqlResult4=$this->dbh->query($sql4);
	return mysql_num_rows($sqlResult4);
}

function get_total_suspend_user()
{
	$sql4="select * from anggota where suspend='Y'";
	$sqlResult4=$this->dbh->query($sql4);
	return mysql_num_rows($sqlResult4);
}

function get_total_unblock_user($get_block)
{
	if($get_block!='')
	$sql4="select * from anggota where user_id not in ($get_block)";
	else
	$sql4="select * from anggota where and deleted='N'";
	$sqlResult4=$this->dbh->query($sql4);
	return mysql_num_rows($sqlResult4);
}

function get_total_block_user()
{
	$sql4="select * from core_block_by_member m left join anggota u on m.member_id=u.user_id order by  block_datetime";
	$sqlResult4=$this->dbh->query($sql4);
	return mysql_num_rows($sqlResult4);
}

function get_total_unnews_user()
{
	$sql4="select * from anggota where newsletter='N' and deleted='N' and user_type!='admin' and user_type!='system'";
	$sqlResult4=$this->dbh->query($sql4);
	return mysql_num_rows($sqlResult4);
}
function get_block_list()
{
	 $sql4="select * from core_block_by_member m left join anggota u on m.member_id=u.user_id order by block_datetime";
	$total_row=$this->dbh->query($sql4);
$TOTAL_RECORDSET=mysql_num_rows($total_row);
$Runngin_list='';

	if($TOTAL_RECORDSET>0)
	{
	while($sqlRow=mysql_fetch_object($total_row))
		{
			if($Runngin_list=='')
				$Runngin_list=$sqlRow->member_id;
			else
			$Runngin_list.=",".$sqlRow->member_id;	
			
		}
	}
	
	return $Runngin_list;
}

function get_total_news_user()
{
	$sql4="select * from anggota where newsletter='Y' and deleted='N' and user_type!='admin' and user_type!='system'";
	$sqlResult4=$this->dbh->query($sql4);
	return mysql_num_rows($sqlResult4);
}

function get_total_upcoming_auction()
{
	$sql4="select * from bid where deleted='N' and system_id='".$_SESSION['admin_id']."' and start='N'";
	$sqlResult4=$this->dbh->query($sql4);
	return mysql_num_rows($sqlResult4);
}

function get_total_open_auction()
{
	$sql4="select title,id,image_path,status,start_auction,end_auction,extends_time,total_days,start_pause,main_auction,sdate,edate,timer_value,running,sequenceid,category,normal_rate,auction_type,robot_system,robot_runtime,target_price,auction_code,quantity_stock,max_frequency,delivery_condition from bid where deleted='N' and status='Y' and system_id='".$_SESSION['admin_id']."' and start='Y' and end_bid!='Y'";
	$sqlResult4=$this->dbh->query($sql4);
	return mysql_num_rows($sqlResult4);
}

function get_total_closed_auction()
{
	$sql4="select * from bid where deleted='N' and end_bid='Y' and system_id='".$_SESSION['admin_id']."' and start='Y'";
	$sqlResult4=$this->dbh->query($sql4);
	return mysql_num_rows($sqlResult4);
}

function Make_images($uploaddir,$filename0)
	{
	
			$thumb_width = 65;
			$thumb_height = 65;
			$thumb_ratio = round($thumb_width/$thumb_height, 2);
			
			$thumb_width1 = 114;
			$thumb_height1 = 85;
			$thumb_ratio1 = round($thumb_width1/$thumb_height1, 2);
			
			$thumb_width2 = 185;
			$thumb_height2 = 165;
			$thumb_ratio2 = round($thumb_width2/$thumb_height2, 2);
			
			$thumb_width3 = 400;
			$thumb_height3 = 310;
			$thumb_ratio3 = round($thumb_width3/$thumb_height3, 2);

			@chmod($uploaddir."/".$filename0, 0755);
			list($width, $height, $type, $attr) = getimagesize("$uploaddir/$filename0");
			//get ratio of width/height
			
			$ratio = round($width/$height, 2);
			
			//make a basic thumbnail
				if($ratio > $thumb_ratio){
					//picture is too wide so we will set the the width to its maximum
					$new_width = $thumb_width;
					$new_height = ceil(($thumb_width*$height)/$width);
				} elseif($ratio < $thumb_ratio){
					//picture is too high so we will set the height to its maximum
					$new_width = ceil(($thumb_height*$width)/$height);
					$new_height = $thumb_height;
				} else {
					//the ratio of the image is the same as the thumbnail
					$new_width = $thumb_width;
					$new_height = $thumb_height;
				}
				
				//time to resize the image and crop it for thumbnail
				$imageEditor = new ImageEditor($filename0, $uploaddir . "/");
				//resize
				$imageEditor->resize($new_width, $new_height);
				//save
				$imageEditor->outputFile($filename0, $uploaddir . "/65N65/");	
			
			
			//make a basic thumbnail
				if($ratio > $thumb_ratio1){
					//picture is too wide so we will set the the width to its maximum
					$new_width1 = $thumb_width1;
					$new_height1 = ceil(($thumb_width1*$height)/$width);
				} elseif($ratio < $thumb_ratio1){
					//picture is too high so we will set the height to its maximum
					$new_width1 = ceil(($thumb_height1*$width)/$height);
					$new_height1 = $thumb_height1;
				} else {
					//the ratio of the image is the same as the thumbnail
					$new_width1 = $thumb_width1;
					$new_height1 = $thumb_height1;
				}
				
				//time to resize the image and crop it for thumbnail
				$imageEditor = new ImageEditor($filename0, $uploaddir . "/");
				//resize
				$imageEditor->resize($new_width1, $new_height1);
				//save
				$imageEditor->outputFile($filename0, $uploaddir . "/114N85/");	

			
			//make a basic thumbnail
				if($ratio > $thumb_ratio2){
					//picture is too wide so we will set the the width to its maximum
					$new_width2 = $thumb_width2;
					$new_height2 = ceil(($thumb_width2*$height)/$width);
				} elseif($ratio < $thumb_ratio2){
					//picture is too high so we will set the height to its maximum
					$new_width2 = ceil(($thumb_height2*$width)/$height);
					$new_height2 = $thumb_height2;
				} else {
					//the ratio of the image is the same as the thumbnail
					$new_width2 = $thumb_width2;
					$new_height2 = $thumb_height2;
				}
				
				//time to resize the image and crop it for thumbnail
				$imageEditor = new ImageEditor($filename0, $uploaddir . "/");
				//resize
				$imageEditor->resize($new_width2, $new_height2);
				//save
				$imageEditor->outputFile($filename0, $uploaddir . "/185N165/");
		
				//make a basic thumbnail
				if($ratio > $thumb_ratio3){
					//picture is too wide so we will set the the width to its maximum
					$new_width3 = $thumb_width3;
					$new_height3 = ceil(($thumb_width3*$height)/$width);
				} elseif($ratio < $thumb_ratio3){
					//picture is too high so we will set the height to its maximum
					$new_width3 = ceil(($thumb_height3*$width)/$height);
					$new_height3 = $thumb_height3;
				} else {
					//the ratio of the image is the same as the thumbnail
					$new_width3 = $thumb_width3;
					$new_height3 = $thumb_height3;
				}
				
				//time to resize the image and crop it for thumbnail
				$imageEditor = new ImageEditor($filename0, $uploaddir . "/");
				//resize
				$imageEditor->resize($new_width3, $new_height3);
				//save
				$imageEditor->outputFile($filename0, $uploaddir . "/400N310/");
	}

function Get_newimage($file_name,$width_to,$height_to)
	{
	return "resizeimage.php?width_to=$width_to&height_to=$height_to&file_name=$file_name";
	}

function nailbiter_won_price($item_id)
{
	$Qry="select bid_amt from add_bids where item_id='$item_id' order by id desc";
	$Res=$this->dbh->query($Qry);
	$Data=@mysql_fetch_object($Res);
	
	return $Data->bid_amt;

}

function watermark_field($field_name)
{
	$Qry="select $field_name from watermark_setting where id='1'";
	$Res=$this->dbh->query($Qry);
	$Data=@mysql_fetch_object($Res);
	
	return $Data->$field_name;
}

function get_water_image($source_path,$start_path,$new_name)
{
$watermark_image=$this->watermark_field('watermark');
$watermark_text=$this->watermark_field('watermark_text');
$watermark_color=$this->watermark_field('watermark_color');
$watermark_size=$this->watermark_field('watermark_size');
list($width, $height, $type, $attr) = getimagesize($source_path);
$last=substr(strrchr($source_path,"."),1);
//Thumbnail sample

$thumb=new Thumb($source_path);	        // Contructor and set source image file

//$thumb->memory_limit='32M';               //[OPTIONAL] set maximun memory usage, default 32 MB ('32M'). (use '16M' or '32M' for litter images)
//$thumb->max_execution_time='30';             //[OPTIONAL] set maximun execution time, default 30 seconds ('30'). (use '60' for big images o slow server)


//$thumb->quality=85;                         // [OPTIONAL] default 75 , only for JPG format
$thumb->output_format=$last;                // [OPTIONAL] JPG | PNG
/*$thumb->jpeg_progressive=0;               // [OPTIONAL] set progressive JPEG : 0 = no , 1 = yes
$thumb->allow_enlarge=false;              // [OPTIONAL] allow to enlarge the thumbnail
//$thumb->CalculateQFactor(10000);          // [OPTIONAL] Calculate JPEG quality factor for a specific size in bytes
//$thumb->bicubic_resample=false;             // [OPTIONAL] set resample algorithm to bicubic
*/

/*
$thumb->img_watermark=$watermark_image;	    // [OPTIONAL] set watermark source file, only PNG format [RECOMENDED ONLY WITH GD 2 ]


$thumb->img_watermark_Valing='TOP';   	    // [OPTIONAL] set watermark vertical position, TOP | CENTER | BOTTON
$thumb->img_watermark_Haling='LEFT';   	    // [OPTIONAL] set watermark horizonatal position, LEFT | CENTER | RIGHT
*/

$thumb->txt_watermark=$watermark_text;	    // [OPTIONAL] set watermark text [RECOMENDED ONLY WITH GD 2 ]
$thumb->txt_watermark_color=$watermark_color;	    // [OPTIONAL] set watermark text color , RGB Hexadecimal[RECOMENDED ONLY WITH GD 2 ]
$thumb->txt_watermark_font=$watermark_size;	            // [OPTIONAL] set watermark text font: 1,2,3,4,5
$thumb->txt_watermark_Valing='BOTTOM';   	// [OPTIONAL] set watermark text vertical position, TOP | CENTER | BOTTOM
$thumb->txt_watermark_Haling='RIGHT';       // [OPTIONAL] set watermark text horizonatal position, LEFT | CENTER | RIGHT
$thumb->txt_watermark_Hmargin=10;           // [OPTIONAL] set watermark text horizonatal margin in pixels
$thumb->txt_watermark_Vmargin=10;           // [OPTIONAL] set watermark text vertical margin in pixels

$thumb->size_width(150);				    // [OPTIONAL] set width for thumbnail, or
$thumb->size_height(113);				    // [OPTIONAL] set height for thumbnail, or
$thumb->size_auto(150);					    // [OPTIONAL] set the biggest width or height for thumbnail

$thumb->size($width,$height);		            // [OPTIONAL] set the biggest width and height for thumbnail

$thumb->process();   				        // generate image

//$thumb->show();						        // show your thumbnail, or

$thumb->save($start_path."watermark_".$new_name.".".$thumb->output_format);			// save your thumbnail to file, or
//$image = $thumb->dump();                  // get the image

//echo ($thumb->error_msg);  

}


function get_bid_field($item_id,$field_name)
{
	$Qry="select $field_name from bid where id='$item_id'";
	$Res=$this->dbh->query($Qry);
	$Data=@mysql_fetch_object($Res);
	
	return $Data->$field_name;
}
function show_texteditor()

{
$qry="select * from language_setting where status='Y'";
$sqlResult4=$this->dbh->query($qry);
return mysql_num_rows($sqlResult4);
}
function get_language()
{
$qry="select language_title  from language_setting where status='Y' and id='".$_SESSION['LANG']."'";
	$qry1=$this->dbh->query($qry);
	$result1=mysql_fetch_object($qry1);
	$title=$result1->language_title;
    return $title;
}
function get_currency($currency)
 	{
		if($currency=='Doller')
			return '$';
		else if($currency=='Rupiah')
			return 'Rp. ';
		else if($currency=='Pound')
			return '&pound;';
	}
function get_active_language()
{
$sql="select * from language_setting where status='Y'";
$Res11=$this->dbh->query($sql);
$Count=@mysql_num_rows($Res11);
return $Count;
}	
function get_language_total()
{
$qry="select language_title  from language_setting where status='Y'";
	$qry1=$this->dbh->query($qry);
	$result1=mysql_fetch_object($qry1);
	$title=$result1->language_title;
    return $title;
}
function get_auction_details($item_id)
{
$qry2="select * from bid_details where status='Y' and deleted='N' and item_id='$item_id' and lang='".$_SESSION['LANG']."'";
$qry1=$this->dbh->query($qry2);
$data = mysql_fetch_object($qry1);
$title=$data->title;
return $title;
}
function get_auction_all_auction($item_id)
{
$qry2="select * from bid_details where status='Y' and deleted='N' and item_id='$item_id'";
$qry1=$this->dbh->query($qry2);
$data = mysql_fetch_object($qry1);
$content=array();
$content[title]=$data->title;
$content[short_description]=$data->short_description;
$content[description]=$data->description;
$content[delivery_info]=$data->delivery_info;

return $content;

}
function get_item_id_bid_details($lang,$des_title)
{
$sql="select item_id from bid_details where status='Y' and deleted='N' and $lang='$lang' and title like '%$des_title%'";
$qry1=$this->dbh->query($sql);
$itemid=array();
$i=0;
while($data=mysql_fetch_object($qry1)) 
{
 $itemid[$i]=$data->item_id;

$i++;
} 

 return $itemid;
}

function Get_language_dropdown($language)
 	{
	$qry1="SELECT * FROM language_setting order by id";
	$Res=$this->dbh->query($qry1);
			
	$Language_dropdown='<select name="id_language" class="selec_drop">';
	while($row=mysql_fetch_object($Res))
		{
		 if($language==$row->id)
			$Language_dropdown.='<option value='.$row->id.' selected>'.$row->language_title.'</option>';
		 else
			$Language_dropdown.='<option value='.$row->id.'>'.$row->language_title.'</option>';	
		}						
							
		    $Language_dropdown.='</select>';

		return $Language_dropdown;	

	}	

}//end of class
?>
				